package m202405.d12;

/**
 * @@author: 爱做梦的锤子
 * @date: 2024/5/12 15:09
 */
public class Q234 {
    public boolean isPalindrome(ListNode head) {
        ListNode temp = new ListNode();
        ListNode p = head;
        while (p != null) {
            ListNode listNode = new ListNode(p.val);
            listNode.next = temp.next;
            temp.next = listNode;
            p = p.next;
        }

        p = head;
        temp = temp.next;
        while (p != null && temp != null) {
            if (p.val != temp.val) {
                return false;
            }
            p = p.next;
            temp = temp.next;
        }
        return true;
    }
}
